package 剑指Offer1;

public class _21对称的二叉树 {
    public class TreeNode {
        int val;
        TreeNode left;
        TreeNode right;
        TreeNode(int x) { val = x; }
    }

    public boolean isSymmetric(TreeNode root) {
        if(root == null) return true;

        return isDuiCheng(root.left,root.right);
    }

    public boolean isDuiCheng(TreeNode left,TreeNode right){
        if(left == null || right == null) return left == right;
        if(left.val!=right.val) return false;
        return isDuiCheng(left.left,right.right) && isDuiCheng(left.right,right.left);
    }
}
